<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <#include "../../common/header.ftl">
</head>
<body class="btn-body">
<input type="hidden" value="${id}" id="driverId">
<div class="container-fluid">
    <#include "../../common/left-nav.ftl">

    <div class="main-box">
        <ol class="breadcrumb crumbs always-top">
            <li><a href="#">司机管理</a></li>
            <li class="active">详情</li>

            <div class="form-btns">
                <a href="${base}/admin/driver/edit?driverId=${id}" type="button" class="btn btn-primary btn-sm">
                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                </a>

                <button type="button" class="btn btn-danger btn-sm" onclick="openRemoveDriver()">
                    <span class="glyphicon glyphicon-trash"></span> 注销
                </button>
            </div>
        </ol>

        <div class="caption">
            <h2 data-field="realName">-</h2>

        </div>

        <div class="container-fluid">
            <div class="detail-div">
                <div class="driver-avatar" style="float:left;">
                    <img src="${base}/res/images/no_pic.png" data-field="avatarPath"
                         data-field-target="img">
                </div>

                <div class="driver-details">
                    <div class="panel panel-info panel-freight">
                        <div class="panel-heading"><b>基础信息</b></div>
                        <div class="panel-body">
                            <div class="details-panel">
                                <div class="item">
                                    <span class="field">姓名</span>
                                    <span class="value" data-field="realName">-</span>
                                </div>

                                <div class="item">
                                    <span class="field">身份证号</span>
                                    <span class="value" data-field="identityNo">-</span>
                                </div>

                                <div class="item">
                                    <span class="field">电话</span>
                                    <span class="value" data-field="tel">-</span>
                                </div>

                                <div class="item">
                                    <span class="field">联系地址</span>
                                    <span class="value" data-field="address">-</span>
                                </div>

                                <div class="item">
                                    <span class="field">运输经营许可</span>
                                    <span class="value" data-field="transportLicense">-</span>
                                </div>

                                <div class="item">
                                    <span class="field">从业资格证</span>
                                    <span class="value" data-field="practicing">-</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="panel panel-info panel-freight">
                        <div class="panel-heading"><b>证件信息</b></div>
                        <div class="panel-body">
                            <div class="details-panel">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="image-box">
                                            <img src="${base}/res/images/no_pic.png" data-field="identityPath"
                                                 data-field-target="img">
                                            <span class="title">身份证</span>
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="image-box">
                                            <img src="${base}/res/images/no_pic.png"
                                                 data-field="transportLicensePath"
                                                 data-field-target="img">
                                            <span class="title">运输经营许可证</span>
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="image-box">
                                            <img src="${base}/res/images/no_pic.png" data-field="practicingPath"
                                                 data-field-target="img">
                                            <span class="title">从业资格证</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="panel panel-info panel-freight">
                        <div class="panel-heading"><b>车辆信息</b></div>
                        <div class="panel-body">
                            <div class="details-panel">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript">
    var driverId = $('#driverId').val();
    $(document).ready(function () {
        $.httpclient.get(API_UCENTER_DRIVER + '/' + driverId, {
            time: new Date().getTime()
        }, function (data) {
            data = data.obj;
            for (var key in data) {
                var item = $('[data-field="' + key + '"]');
                if (item) {
                    var target = item.data('field-target');
                    var value = data[key];
                    if (target === 'img' && value) {
                        item.attr('src', $('#base').val() + '/file/image/' + value);
                    } else {
                        item.text(data[key]);
                    }

                }
            }
        })
    })

    function openRemoveDriver() {
        bootbox.confirm({
            message: "是否确认注销该司机信息?",
            buttons: {
                confirm: {
                    label: '是',
                    className: 'btn-success'
                },
                cancel: {
                    label: '否',
                    className: 'btn-danger'
                }
            },
            callback: function (result) {
                if (result) {
                    $.httpclient.delete(API_UCENTER_DRIVER + '/' + driverId, null, function (data) {
                        if (data.code === 'SUCCESS') {
                            location.href = $('#base').val() + '/admin/driver';
                        } else {
                            bootbox.alert(data.message);
                        }

                    })
                }
            }
        });
    }
</script>